/*
 * ProducerConsumerTest.h
 *
 *  Created on: Feb 9, 2010
 *      Author: Jamie LaPointe
 */

#ifndef PRODUCERCONSUMERTEST_H_
#define PRODUCERCONSUMERTEST_H_

#include "ProducerConsumerShared.h"
#include "Producer.h"
#include "Consumer.h"
#include "Log.h"
#include "TestData.h"

namespace ProducerConsumer
{

// forward declaration
class TestData;

class ProducerConsumerTest
{
private:
   //
   // static constants
   //
   static const int numConsumerThreads = 5;
   static const int numProducerThreads = 5;
   static const int maxSizeList = 5;
   static const int maxIterations = 100;

   //
   // shared data
   //
   Common::ProducerConsumerShared * sharedData;
   Producer::Producer * producer;
   Consumer::Consumer * consumer;
   Logger::Log * log;

   int producerThreadIndex;
   int consumerThreadIndex;

   //
   // Print mutex for atomic prints... do I need this on both Win32 & Linux?
   //
   //static pthread_mutex_t printMutex;

   //
   // Producer and Consumer thread entry points
   //
   static void * producerTest(void * arg);
   static void * consumerTest(void * arg);

   // disallow copying and the equal operator
   ProducerConsumerTest(const ProducerConsumerTest & rhs);
   ProducerConsumerTest& operator=(const ProducerConsumerTest&);

public:
   ProducerConsumerTest();
   ~ProducerConsumerTest();

   void Run();

}; // class ProducerConsumerTest

} // namespace ProducerConsumer

#endif /* PRODUCERCONSUMERTEST_H_ */
